dojo.provide("dojot.util.PageDataStore");
dojo.require("dojo.io.script");
dojo.require("dojo.io.iframe");
dojo.declare("dojot.util.PageDataStore",null,{
	requestUrl:"",
	_requestCount:0,
	constructor: function(url){
		this.requestUrl = url　|| this.requestUrl;
	},
	getData: function(pageInfo){
		//把上一个callback函数给清空
		dojo.global["fn"+this._requestCount] = function(){
		};
		//生成一个新的callback函数
		var callbackFn = ("fn"+(++this._requestCount));

		dojo.global[callbackFn] = function(response, ioArgs){
			//因为在ie下面对数据请求有缓存，所以加了延时处理，否则会出错。
			setTimeout(function(){
				dojo.publish("show",[response]);
			},100);
		}
		var _createContent = function(callback){
			return {
				callback:callback
			};
		};		
		var reqlUrl = this._getRealUrl(pageInfo);
		dojo.io.script.get({
			url: reqlUrl,
			content:_createContent(callbackFn),
			error : function(response, ioArgs) {
				return response;
			}
		});
	},
	getData2: function(pageInfo){
		//把上一个callback函数给清空
		var reqlUrl = this._getRealUrl(pageInfo);
		alert("reqlUrl-->"+this._getRealUrl(pageInfo));
		dojo.io.script.get({
			url: reqlUrl,
			load:function(response){
				alert("response-->"+response);
				dojo.publish("show",[response]);
			},
			timeout: 6000,
			error : function(response, ioArgs) {
				 alert(response.toString()); 
				return response;
			}
		});
	},
	getData3: function(pageInfo){
		//把上一个callback函数给清空
		var reqlUrl = this._getRealUrl(pageInfo);
		alert("reqlUrl-->"+this._getRealUrl(pageInfo));
		dojo.io.iframe.send({
		    method: "GET",
		    url: reqlUrl,
		    callbackParamName : "callback",
		    load: function(data){
		         alert("==="); // successful response
		    },
		    error : function(response, ioArgs) {
			 alert(response.toString()); 
				return response;
			}
		});
	},
	setRequestUrl: function(url){
		this.requestUrl = url;
	},
	_getRealUrl: function(pageInfo){
		return dojo.string.substitute(this.requestUrl,pageInfo);
	}

})